{extend name="template/base_default"}
{block name="header"}
<link rel="stylesheet" href="__CSS__/common.css">
<link rel="stylesheet" href="__CSS__/weui.min.css">
<link rel="stylesheet" href="__CSS__/index.css">
<link rel="stylesheet" href="__CSS__/weuix.min.css"/>
<script src="__JS__/zepto.min.js"></script>
<script src="__JS__/lrz.min.js"></script>
<style>

    .form-head{
        color: white;
        font-size: 16px;
        background-color: rgba(255, 255, 255, 0.2);
        border-radius: 5px;
        overflow: hidden;
        padding-top:10px;
    }
    body{
        background-image:url("__IMG__/bj.png");
        background-repeat:no-repeat;
        background-size:cover;
        text-align: center;
        background-attachment:fixed;
    }
    .body-input{
        outline: none;
        color: #dddddd;
        position: relative;
        border: solid 1px #ffffff;
        background-color: rgba(255, 255, 255, 0);
        float: left;
        margin: auto;
        font-size: 16px;
        height: 41px;
        line-height: 41px;
        border-radius: 5px;
        width: 60%;
        font-family: "Microsoft YaHei UI";
    }
    .bottom-btn{
        width:100%;
        height:100%;
        float: left;
    }
    button{
        border: none;
        color:white;
    }
    .botton1{
        background-color: #FF0000;
    }
    .botton2{
        background-color: #00a0e9;
    }
    .input-window{
        margin-left: auto;
        margin-right: auto;
        background-color: rgba(255,255,255, 0.8);
        background-color: white;
        height:90px;
        width:90px;
        border-radius: 10px;
        margin-top: 30px;
    }
    .aa{
        height:3px;
        background-color: white;
        width:40px;
        position:absolute;
        top: 30px;
        left:55px;
    }
    .bb{
        width: 100%;
        height: 100%;
        opacity: 0;
        -webkit-tap-highlight-color: rgba(0,0,0,0);
    }
</style>
{/block}
{block name="body"}

<form action="{:url('login/register')}" method="post" style="width:95%;margin: auto">
    <div class="form-head" style="height:300px;margin-top:10px;">
        <input class="form-input3-input" id="seller_id" name="seller_id" type="hidden" value="{$seller_id}" placeholder=" ">
        <div class="form-input3" >
            <label for="title" class="form-input3-label">标题:</label>
            <input style="padding-left:" class="form-input3-input" id="title" name="title" type="text" value="" placeholder=" ">
        </div>
        <div class="form-input3" style="height:170px">
            <label for="detail" class="form-input3-label" >内容:</label>
            <textarea class="body-input" name="detail" id="detail" type="text" value="" style="height:160px;line-height: 30px;" rows="50" cols="3"></textarea>
            <!--<input class="body-input" name="sex" id="sex" type="text" value="" style="height:160px;line-height: 30px;">-->
        </div>



    </div>
    <div class="form-body">
        <div class="input-window" style="background-image: url(__IMG__/1313.png);background-size: cover">

            <input class="bb headimgurl" type="file" accept="image/jpg,image/jpeg,image/png,image/gif"   />
            <input  type="hidden" id="img" value="0" />
        </div>
    </div>
    <div style="position:fixed;bottom:0;left:0;width:100%;height:50px;">
        <button id="submit" class="bottom-btn botton2" type="button">提交</button>
    </div>

</form>
{/block}
{block name="footer"}
<script type="text/javascript" src="__JS__/public.js"></script>
<script>
    $(function(){

        $('.headimgurl').change(function () {
            var v_this = $(this);
            lrz(this.files[0],{width:640,fieldName:"image"}).then(function (rst) {
                var formdata = new FormData();
                v_this.parent().css("background-image","url("+rst.base64+")");//无论是否上传成功都显示
                url = getBaseUrl()+"web.php/file/upload_picture_base64";
                formdata.append("image", rst.base64);
                $.ajax({
                    url : url,
                    type : 'post',
                    data : formdata,
                    contentType : false,
                    processData : false,
                    dataType : "json",
                    success : function(data) {
                        if (data.status == true) {
                            $.toast("图片上传成功");
                            v_this.next().val(data.info[0]['id']);
                        }
                    },
                    error:function(){
                        $.toast("图片上传失败");
                    }
                });
                return false;
            })
        });
    })
    $('#submit').click(function () {
            var body  ={
                seller_id:$('#seller_id').val(),
                title:$('#title').val(),
                detail:$('#detail').val(),
                img:$('#img').val(),

            };
            var $this = $(this);
            $this.addClass('weui-btn_disabled').attr('disabled','disabled');
            ajax_post(getBaseUrl()+'web.php/extension/add_charge',jQuery.param(body),{
                success:function(data){
                    $.toast("添加成功",'success');
                    $this.removeClass('weui-btn_disabled').removeAttr("disabled");
                    setTimeout(
                        function(){
                            history.back(-1);
                        }
                        ,1500);
                },
                error:function(data){
                    $.toptip('添加失败', 'error');
                    $this.removeClass('weui-btn_disabled').removeAttr("disabled");
                }
            })


    });
</script>
{/block}